package com.example.gorannet;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
import android.widget.Toast;

public class AppSettingsActivity extends Activity {
    EditText t;
    MyChoices ob = new MyChoices();

    BootstrapButton reg, setBtn,toggle;
    private EditText                      name, email, sql_edittext;

    private AlertDialogManager            alert           = new AlertDialogManager();

    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.system_settings_layout);
        TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
        tabHost.setup();
        gcm(tabHost);

        sql_edittext = (EditText)findViewById(R.id.sql_edittext);
        setBtn = (BootstrapButton)findViewById(R.id.set_btn);
        name = (EditText)findViewById(R.id.subj);
        email = (EditText)findViewById(R.id.txtEmail);
        reg = (BootstrapButton)findViewById(R.id.btnRegister);
        reg.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String name1 = name.getText().toString();
                String email1 = email.getText().toString();

                // Check if user filled the form
                if (name1.trim().length() > 0 && email1.trim().length() > 0)
                {
                    // Launch Main Activity
                    Intent i = new Intent(getApplicationContext(), MainActivity.class);

                    // Registering user on our server
                    // Sending registration details to MainActivity
                    i.putExtra("name", name1);
                    i.putExtra("email", email1);
                    startActivity(i);

                    // finish();
                }
                else
                {
                    // user doen't filled that data
                    // ask him to fill the form
                	alert.showAlertDialog(AppSettingsActivity.this, "Registration Error!",
	                        "Please enter your details", false);
                }
            }
        });
        setBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                int a =Integer.parseInt(sql_edittext.getText().toString())+1;

                Toast.makeText(getApplicationContext(), a+"", Toast.LENGTH_LONG).show();
            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
        MenuInflater menuInflater = getMenuInflater();
        menuInflater.inflate(R.layout.menu, menu);
        return true;
    }
    public void gcm(TabHost tabHost)
    {

        TabSpec ts = tabHost.newTabSpec("tag1");
        ts.setContent(R.id.tab1);
        ts.setIndicator("GCM");
        tabHost.addTab(ts);

        ts = tabHost.newTabSpec("tag2");
        ts.setContent(R.id.tab2);
        ts.setIndicator("SQL");
        tabHost.addTab(ts);


    }
}